package com.vince.test;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 
 * @author susp
 *
 */
@WebServlet("/requestheader")
public class GetRequestHeader extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		//获取全部的header信息
		Enumeration<String> headers=request.getHeaderNames();
		while(headers.hasMoreElements()){
			//取出消息头的名字
			String headername=headers.nextElement();
			System.out.println(headername+":"+request.getHeader(headername));
			
		}		
	}

}
